package week02

// 374. 猜数字大小
// https://leetcode-cn.com/problems/guess-number-higher-or-lower/

func guessNumber(n int) int {
	var left, right = 0, n
	for {
		var mid = (right - left) / 2 + left
		switch guess(mid) {
		case 0:
			return mid
		case -1:
			right = mid
		case 1:
			left = mid + 1
		}
	}
}
